<?php
header("content-type:text/html;charset=utf8");
// print_r($_POST);
$username = $_POST["username"];
$password = $_POST["password"];
// print_r($username);
// print_r($password);
// 连接数据库
$con = mysqli_connect('localhost','root','root','hf_2102');
// print_r($con);
// 解决乱码
mysqli_query($con,'set names utf8');
$res = mysqli_query($con,"select * from user where username = '$username'");
$row = mysqli_fetch_assoc($res);
// print_r($row);
if($row){
    $row_password = $row['password'];
    if($password == $row_password){
        echo '<script>
            alert("登陆成功");
            location.href = "../html/shouye.html";
        </script>';
    }else{
        echo '<script>
            alert("密码错误");
            location.href = "../html/login.html";
        </script>';
    }
}else{
    echo '<script>
        alert("用户名没有注册过");
        location.href = "../html/register.html";
    </script>';
}


